package com.leizi.igym.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 
 * @TableName t_plan
 */
@TableName(value ="t_plan")
@Data
@Document(indexName = "plan")
public class Plan implements Serializable {
    /**
     * 计划id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    @Id
    private Long id;

    /**
     * 创建人id
     */
    @TableField(value = "user_id")
    @JsonSerialize(using = ToStringSerializer.class)
    @Field(type = FieldType.Long)
    private Long userId;

    /**
     * 计划标题
     */
    @TableField(value = "title")
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String title;

    /**
     * 计划内容
     */
    @TableField(value = "content")
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String content;

    /**
     * 计划实施日期
     */
    @TableField(value = "do_date")
    @Field(type = FieldType.Date,format ={},pattern = "yyyy-MM-dd" )
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate doDate;

    /**
     * 计划完成状态
     */
    @TableField(value = "status")
    @Field(type = FieldType.Integer,index = false)
    private Integer status;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    @Field(type = FieldType.Date,format ={},pattern = "yyyy-MM-dd HH:mm:ss" )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    @Field(type = FieldType.Date,format ={},pattern = "yyyy-MM-dd HH:mm:ss" )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 逻辑删除
     */
    @TableField(value = "deleted")
    @Field(type = FieldType.Integer)
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}